
<template>
  <div class="header">
    <div class="timeBox">
      <p>{{ new Date().getDate() }}</p>
      <p>{{ toChinesNum(new Date().getMonth() + 1) }}月</p>
    </div>
    <p class="h_title">知乎日报</p>
    <span @click="loginOrUser(isLogin)">
      <img class="userImg" v-if="!isLogin" src="@/assets/logo.png" alt />
      <img class="userImg" v-else :src="user.userImg" alt />
    </span>
  </div>
</template>


<script lang="ts">
import { defineComponent, computed } from "vue";
import { useStore } from "vuex";
import { toChinesNum, loginOrUser } from "@/components/Header/header";

export default defineComponent({
  setup() {
    const store = useStore();
    let isLogin = computed(() => store.state.login.isLogin);
    let user = computed(() => store.state.login.user);
    return { toChinesNum, isLogin, user, loginOrUser };
  },
});
</script>

<style lang="scss" scoped>
.header {
  height: 0.5rem;
  border-bottom: 1px solid #ccc;
  display: flex;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  background: #fff;
  z-index: 99;
}
.timeBox {
  padding: 0 0.1rem;
  margin: 0.05rem 0.1rem 0.05rem 0;
  border-right: 0.01rem solid #aaa;
  text-align: center;
  p {
    font-size: 0.12rem;
  }
  p:nth-child(1) {
    font-weight: 700;
    font-size: 0.22rem;
  }
}
.h_title {
  flex: 1;
  font-weight: 700;
  font-size: 0.24rem;
  line-height: 0.5rem;
}
.userImg {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  margin: 0.05rem 0.05rem 0 0;
}
</style>